# Maintainer: Rafal Brzegowy <rafal.brzegowy@yahoo.com>

_realname=starpu
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=1.3.7
pkgrel=2
pkgdesc='StarPU is a task programming library for hybrid architectures (mingw-w64)'
arch=('any')
depends=("${MINGW_PACKAGE_PREFIX}-fftw"
         "${MINGW_PACKAGE_PREFIX}-libtool")
makedepends=("${MINGW_PACKAGE_PREFIX}-hwloc")
options=('!docs')
license=('LGPL')
url='https://starpu.gitlabpages.inria.fr'
source=(https://files.inria.fr/starpu/${_realname}-${pkgver}/${_realname}-${pkgver}.tar.gz
        0000-fix.patch)
#temporary fix: https://prod-gitlab.inria.fr/starpu/starpu/-/commit/11ade2e903c49ebddc4d4b85bc63c3ead36d844a
sha256sums=('1D7E01567FBD4A66B7E563626899374735E37883226AFB96C8952FEA1DAB77C2'
            '9D4CD10013A3CAA38C71CE0A1C388D5BABB80047948FD4BC361C3A22C43BCF80')

prepare() {
  cd ${_realname}-${pkgver}
  patch -p1 -i "${srcdir}/0000-fix.patch"
  autoreconf -fiv
}

build() {
  [[ -d "${srcdir}/build-${MINGW_CHOST}" ]] && rm -rf "${srcdir}/build-${MINGW_CHOST}"
  mkdir -p "${srcdir}/build-${MINGW_CHOST}" && cd "${srcdir}/build-${MINGW_CHOST}"

  ../${_realname}-${pkgver}/configure \
    LDFLAGS=-lssp \
    --prefix=${MINGW_PREFIX} \
    --disable-opencl \
    --with-gnu-ld \
    --disable-mpi \
    --disable-build-doc \
    --disable-build-examples \
    --enable-quick-check

  make
}

check() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make check || true
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make install DESTDIR="${pkgdir}"
  install -Dm644 ${srcdir}/${_realname}-${pkgver}/COPYING.LGPL ${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE
}

# vim: ts=2 sw=2 et:
